<template>
	<view>
		<header-top :messageInfo="{typeFlag:false,message:'',liner:true}"></header-top>
		<view class="mainpadding_top"> 
			<view class="logintext">欢迎登录询博订货管理端</view>
			<view class="mainpadding_top">
				<view class="needbot-bor">
					<input type="number" placeholder="请输入账号" v-model="mobile">
				</view>
				<view class="needbot-bor flexbetween">
					<input type="password" placeholder="请输入密码" v-model="password">
				</view>
				<view class="flexright margin_top">
					<view class="flexright nostrongtext" @click="jumpurl('/pages/login/forgetpassword')">忘记密码？</view>
					<!-- <view class="flexright nostrongtext" @click="jumpurl('/pages/login/thelogin')">短信验证码登录</view> -->
				</view>
			</view>
		</view>
		<view class="mainpadding_top">
			<view class="surebtns flexcenter margin_top" @click="login">同意协议并登录</view>
			<view class="margin_top flexleft" @click="checkbtn">
				<view class="leftradio">
					<!-- 选中 -->
					<view v-show="checkbox" class="selecticon">
						<image src="@/static/image/system/dui.png" mode=""></image>
					</view>
					<!-- 未选中 -->
					<view v-show="!checkbox" class="noselecticon"></view>
				</view>
				<view class="">
					<text class="smalltext">登录即代表已阅读并同意</text>
					<text class="smalltext maincolor_text" @click.stop="jumpurl('/pages/systempage/systempage?type=1')">《使用协议》</text>  
					<text class="smalltext">和</text>
					<text class="smalltext maincolor_text" @click.stop="jumpurl('/pages/systempage/systempage?type=2')">《隐私政策》</text>  
				</view>
				
			</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				checkbox:false,
				mobile:"",
				password:"",
			}
		},
		methods: {
			//验证手机号
			isMobile(value) {
				let a = /^1[3|4|5|6|7|8|9][0-9]\d{8}$/.test(value); 
				return a;
			},
			login(){
				if(this.mobile==""){
					httpRequest.toast("请输入手机号");
					return false;
				}
				if(!this.isMobile(this.mobile)){
					httpRequest.toast("手机号码格式错误!")
					return;
				}
				if(this.password==""){
					httpRequest.toast("请输入密码12")
					return false
				} 
				if(!this.checkbox){
					httpRequest.toast("请认真阅读并勾选使用协议");
					return false;
				}
				httpRequest.request('/dhtapi/user/login','GET',{
					account:this.mobile, 
					password:this.password
				}).then(res => {
					if(res.code == 1){
						httpRequest.toast('登录成功');
						uni.setStorageSync('token',res.data.userinfo.token);
						uni.setStorageSync('user_id',res.data.userinfo.user_id);
						uni.reLaunch({
							url:'/pages/homepage/homepage'
						})
					}else{
						httpRequest.toast(res.msg);
					}
				})
				
			},
			checkbtn(){
				this.checkbox = this.checkbox==true?false:true;
			},
			jumpurl(url){
				uni.navigateTo({
					url:url
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.logintext{
		font-size: 40rpx;
		font-family: PingFang SC-Bold, PingFang SC;
		font-weight: bold;
		color: #000000;
		line-height: 47rpx;
	}
	.needbot-bor{
		margin-top: 40rpx;
		padding-bottom: 20rpx;
		border-bottom: 1rpx solid rgba(153, 153, 153, 0.06);
	}
	.sendcode{
		width: 140rpx;
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #00B855;
	}
	.nostrongtext{
		font-weight: 500;
	}
	.smalltext{
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #999999;
	}
	.maincolor_text{
		color: #00B855;
	}
	.leftradio{
		margin-right: 10rpx;
	}
	// 选中的单选按钮
	.selecticon{
			  width: 30rpx;
			  height: 30rpx;
			  border-radius: 50%;
			  border: 1rpx solid #00B855;
			  background-color: #00B855;
			  image {
			  	width: 20rpx;
			  	height: 12rpx;
			  	margin-bottom: 15rpx;
			  	margin-left: 5rpx;
			  }
			}
	// 未选中的单选按钮
	.noselecticon{
			  width: 30rpx;
			  height: 30rpx;
			  border-radius: 50%;
			  border: 1rpx solid #999999;
	}
</style>
